/**
 * 
 */
package name.shamansir.tadah.data.scheduling;

import android.text.format.Time;

/**
 * <dl>
 * <dt>Project:</dt> <dd>ta-dah</dd>
 * <dt>Package:</dt> <dd>name.shamansir.tadah.data.scheduling</dd>
 * </dl>
 *
 * <code>Run</code>
 *
 * <p>Description</p>
 *
 * @author Ulric Wilfred <shaman.sir@gmail.com>
 * @date Feb 22, 2011 8:47:36 PM 
 *
 */
public class Run implements HasDuration {
    
    private final Time start;
    private final Time end;
    
    public Run(Time start, Time end) {
        this.start = start;
        this.end = end;
    }
    
    public Time getStart() { return start; }
    public Time getEnd() { return end; }
    
    public boolean hasStart() { return start != null; }    
    public boolean hasEnd() { return end != null; }
    public boolean noStart() { return start == null; }    
    public boolean noEnd() { return end == null; }    

    @Override
    public Run match(Time start, Time end) {
        if (start.equals(end)) return null;
        // FIXME: implement
        return null;
    }
    
    public void longsFor(int amount, Occurrence period) {
        // FIXME: implement
    }
    
    public static Run byDuration(Time start, int amount, Occurrence period) {
        final Run run = new Run(start, null);
        run.longsFor(amount, period);
        return run;
    }    
    
    @Override
    public boolean equals(Object other) {
        if (other == null) return false;
        if (other instanceof Run) return start.equals(((Run)other).start) &&
                                            end.equals(((Run)other).end);
        return false;
    }       
    
    @Override
    public int hashCode() {
        return (start.hashCode() << 16) &
               end.hashCode(); 
    }
    
    
    

}
